package com.lyh.system.service.impl;

import java.util.*;

import com.lyh.common.utils.DateUtils;
import com.lyh.common.utils.StringUtils;
import com.lyh.system.domain.req.RechargeRecordReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lyh.system.mapper.RechargeRecordMapper;
import com.lyh.system.domain.RechargeRecord;
import com.lyh.system.service.IRechargeRecordService;

/**
 * 支付记录Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-27
 */
@Service
public class RechargeRecordServiceImpl implements IRechargeRecordService
{
    @Autowired
    private RechargeRecordMapper rechargeRecordMapper;

    /**
     * 查询支付记录
     *
     * @param id 支付记录主键
     * @return 支付记录
     */
    @Override
    public RechargeRecord selectRechargeRecordById(Long id)
    {
        return rechargeRecordMapper.selectRechargeRecordById(id);
    }

    /**
     * 查询支付记录列表
     *
     * @param rechargeRecord 支付记录
     * @return 支付记录
     */
    @Override
    public List<RechargeRecord> selectRechargeRecordList(RechargeRecordReq rechargeRecord)
    {
        if(StringUtils.isNotEmpty(rechargeRecord.getListStr())){
            rechargeRecord.setList( Arrays.asList(rechargeRecord.getListStr().split(",")));
        }
        return rechargeRecordMapper.selectRechargeRecordList(rechargeRecord);
    }

    /**
     * 新增支付记录
     *
     * @param rechargeRecord 支付记录
     * @return 结果
     */
    @Override
    public int insertRechargeRecord(RechargeRecord rechargeRecord)
    {
        return rechargeRecordMapper.insertRechargeRecord(rechargeRecord);
    }

    /**
     * 修改支付记录
     *
     * @param rechargeRecord 支付记录
     * @return 结果
     */
    @Override
    public int updateRechargeRecord(RechargeRecord rechargeRecord)
    {
        return rechargeRecordMapper.updateRechargeRecord(rechargeRecord);
    }

    /**
     * 批量删除支付记录
     *
     * @param ids 需要删除的支付记录主键
     * @return 结果
     */
    @Override
    public int deleteRechargeRecordByIds(Long[] ids)
    {
        return rechargeRecordMapper.deleteRechargeRecordByIds(ids);
    }

    /**
     * 删除支付记录信息
     *
     * @param id 支付记录主键
     * @return 结果
     */
    @Override
    public int deleteRechargeRecordById(Long id)
    {
        return rechargeRecordMapper.deleteRechargeRecordById(id);
    }

    @Override
    public Map<String, Object> getWebAllNum() {
        Integer webAllNum = rechargeRecordMapper.getWebAllNum(null);
        Integer webAllNum1 = rechargeRecordMapper.getWebAllNum(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date()));
        Map<String, Object> map = new HashMap<>();
        map.put("allNum",webAllNum == null ? 0 :webAllNum);
        map.put("todayNum",webAllNum1  == null ? 0 :webAllNum1 );
        return map;
    }
}
